package com.startech.common.domain.vo;

import lombok.Data;

@Data
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    public static<T> Result<T> success(){
        Result<T> result = new Result<>();
        result.setCode(1);
        result.setMsg("操作成功");
        result.setData(null);
        return result;
    }
    public static<T> Result<T> success(T data){
        Result<T> result = new Result<>();
        result.setCode(1);
        result.setMsg("操作成功");
        result.setData(data);
        return result;
    }
    public static<T> Result<T> success(String msg,T data){
        Result<T> result = new Result<>();
        result.setCode(1);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static<T> Result<T> error(String msg){
        Result<T> result = new Result<>();
        result.setCode(0);
        result.setMsg(msg);
        return result;
    }
    public static<T> Result<T> error(String msg,T data){
        Result<T> result = new Result<>();
        result.setData(data);
        result.setCode(0);
        result.setMsg(msg);
        return result;
    }
    public static<T> Result<T> error(Integer code,String msg){
        Result<T> result = new Result<>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}
